<?php
/**
* phpCan - http://idc.anavallasuiza.com/
*
* phpCan is released under the GNU Affero GPL version 3
*
* More information at license.txt
*/
defined('ANS') or die();

//phpCan version
define('PHPCAN_VERSION', '1.0');

//Base paths
define('DOMAIN_CONFIG_PATH', getenv('SERVER_NAME').'/');
define('DEFAULT_CONFIG_PATH', 'default/');
define('BASE_PATH', dirname(__DIR__).'/');
define('BASE_WWW', preg_replace('#/+#', '/', '/'.preg_replace('|^'.getenv('DOCUMENT_ROOT').'|i', '', BASE_PATH)));
define('PHPCAN_PATH', BASE_PATH.'phpcan/');

//Include basic functions and classes
require_once(PHPCAN_PATH.'includes/functions.php');

$Debug = new Debug;
$Config = new Config;
$Vars = new Vars;

//Load basic configuration
$Config->load('paths.php', PHPCAN_PATH.'config/');
$Config->load('scenes.php', PHPCAN_PATH.'config/');

$Debug->setSettings();

//Detect scene and module
$Vars->load();
$Vars->setScene();
$Vars->setModule();

//Scene paths
define('SCENE_PATH', BASE_PATH.$Vars->getSceneConfig('folder'));
define('SCENE_WWW', BASE_WWW.($Vars->getSceneConfig('detect', 'subfolder') && !$Vars->getSceneConfig('default') ? $Vars->getScene().'/' : ''));
define('SCENE_REAL_WWW', BASE_WWW.$Vars->getScene().'/');

$Config->load('paths.php', 'scene');

//Module paths
if ($Vars->getModule()) {
	define('MODULE_PATH', BASE_PATH.$Config->phpcan_paths['modules'].$Vars->getModuleConfig('folder'));
	define('MODULE_WWW', SCENE_WWW.($Vars->getModuleConfig('detect', 'subfolder') ? $Vars->getModule().'/' : ''));
	define('MODULE_REAL_WWW', BASE_WWW.$Config->phpcan_paths['modules'].$Vars->getModule().'/');

	$Config->load('paths.php', 'module');
}
?>
